#pragma once

#include <linux/thread_info.h>

/*
 * switch_to(prev, next) should switch from task `prev' to `next'
 * `prev' will never be the same as `next'.  schedule() itself
 * contains the memory barrier to tell GCC not to cache `current'.
 */
extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *,
                                       struct task_struct *, struct thread_info *);
extern void set_current(struct task_struct *p);

#define switch_to(prev, next, last)             \
    do                                          \
    {                                           \
        void *p, *n;                            \
        p = &((prev)->thread_info.cpu_context); \
        n = &((next)->thread_info.cpu_context); \
        set_current(next);                      \
        last = __switch_to(prev, p, next, n);   \
    } while (0)
